<?php

 class Car{
   public $color;
   public $username;
   public function __construct($color,$username)
   {
       $this->color=$color;
       $this->username=$username;
   }
   public function use(){
       echo "我是机动车!";
   }
   public function equals($obj1,$obj2){
       if(($obj1->color==$obj2->color)&&($obj1->username==$obj2->username)){
           echo "相等";
       }else{
           echo "不相等";
       }
   }
 }


 class Taxi extends Car{
     public $company;
     public function __construct($color,$username,$company)
     {
       $this->company=$company;
       Car::__construct($color,$username);
     }
     final function ride(){
       echo $this->username."出租⻋是所属于在".$this->company.'公司的';
     }
     function use(){
         echo "出租⻋是提⾼市⺠⽣活质量的重要条件之⼀";
     }
     function toString()
     {
         echo $this->color;
         echo $this->username;
     }
 }

//  $taxi=new Taxi('red','lisi','wangwu');
//  echo '<br/>';
//  $taxi->ride();
//  $taxi->use();
//  $taxi->toString();

final class HomeCar extends Car{
    public $num;
    public function __construct($username,$color,$num)
    { 
        $this->num=$num;
        Car::__construct($color,$username);
    }
    function display(){
        echo $this->username."拥有的".$this->color."颜⾊的私家⻋有".$this->num."座位";
    }
}

// echo '<br/>';
// $homecar=new HomeCar('lili','粉色','5');
// $homecar->display();

 
$car1=new Car('red','zhangsan');
$car2=new Car('red','zhangsan');
$car1->use();
$car1->equals($car1,$car2);

$taxi=new Taxi('red','lisi','wangwu');
echo '<br/>';
$taxi->ride();
$taxi->use();

echo '<br/>';
$homecar=new HomeCar('lili','粉色','5');
$homecar->display();
?>